home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-12-05 | 1.2 KB | 64 lines | [TEXT/MPS ] |
- C This example Trims blanks off the front of a character.
- C
- C Function LTRIM -
- C
- C Takes a string or a character as input.
- C
- C Returns a Pascal-type string as a result.
- C
- C
- C Example provided for owners of Language Systems FORTRAN
- C © 1990 Language Systems Corp.
- C
- C Written by Steven Hopkins
- C
- string function LTRIM(Char_Str_Arg)
-
- C receive the argument by Descriptor
-
- structure /DescRec/
- pointer /character*1/ DataPtr
- integer*2 DataSize
- integer*2 SymT
- end structure
- record /DescRec/ Char_Str_Arg
-
- C Local Declarations
-
- integer*4 chard,strngd
- parameter (chard=18,strngd=19)
- pointer /character*1/ Char_Str_Ptr
- integer*4 size, count
-
- C point to the character argument
-
- Char_Str_Ptr = Char_Str_Arg.DataPtr
-
- C Decide if Argument is a Character or String
- c and store the size
-
- if (Char_Str_Arg.SymT = strngd) then
- size = MIN(255,ichar(Char_Str_Ptr^))
- Char_Str_Ptr = Char_Str_Ptr + 1
- else
- size = MIN(Char_Str_Arg.DataSize,255)
- end if
-
- C count the number of blanks
-
- count = 0
- do while ((count < size) .and. (Char_Str_Ptr^ = ' '))
- Char_Str_Ptr = Char_Str_Ptr + 1
- count = count + 1
- end do
-
- C return the trimmed argument
-
- if (count < size) then
- LTRIM = Char_Str_Ptr^(1:(size-count))
- else
- LTRIM = ''
- end if
-
- end
-